from time import sleep

from selenium import  webdriver

from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import  expected_conditions#
from selenium.webdriver.support.select import Select
driver = webdriver.Chrome()
# driver.implicitly_wait(5)
driver.get("http://192.168.1.138/ranzhi/www/sys/index.html")
driver.maximize_window()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,'//*[@id="account"]')))
driver.find_element(By.XPATH, '//*[@id="account"]').send_keys("admin")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,'//*[@id="password"]')))
driver.find_element(By.XPATH, '//*[@id="password"]').send_keys("123456")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,'//*[@id="submit"]')))
driver.find_element(By.XPATH, '//*[@id="submit"]').click()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,'//*[@id="s-menu-1"]/button/img')))
driver.find_element(By.XPATH,'//*[@id="s-menu-1"]/button/img').click()
WebDriverWait(driver,10).until(expected_conditions.frame_to_be_available_and_switch_to_it("iframe-1"))
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,'//*[@id="mainNavbar"]/ul/li[4]/a')))
driver.find_element(By.XPATH,'//*[@id="mainNavbar"]/ul/li[4]/a').click()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.XPATH,'//*[@id="menuActions"]/a')))
driver.find_element(By.XPATH,'//*[@id="menuActions"]/a').click()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"name")))
driver.find_element(By.ID,"name").send_keys("子龙")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"public")))
driver.find_element(By.ID,"public").click()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"contact")))
driver.find_element(By.ID,"contact").send_keys("赵云")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"phone")))
driver.find_element(By.ID,"phone").send_keys("123456789")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"email")))
driver.find_element(By.ID,"email").send_keys("l28666666@gmail.com")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"qq")))
driver.find_element(By.ID,"qq").send_keys("120943389")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"depositor")))
driver.find_element(By.ID,"depositor").send_keys("l2866666.com")


ele = WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"type")))
sle_obj=Select(ele)
sle_obj.select_by_value("foreign")

ele1 = WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"size")))
sle_obj1=Select(ele1)
sle_obj1.select_by_value("1")

ele2 = WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"status")))
sle_obj2=Select(ele2)
sle_obj2.select_by_value("signed")

ele3 = WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"level")))
sle_obj3=Select(ele3)
sle_obj3.select_by_value("A")

WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.NAME,"address[title]")))
driver.find_element(By.NAME,"address[title]").send_keys("陕西省西安市")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"addresslocation")))
driver.find_element(By.ID,"addresslocation").send_keys("陕西省西安市凤城")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.NAME,"intension")))
driver.find_element(By.NAME,"intension").send_keys("非常大")
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.ID,"submit")))
driver.find_element(By.ID,"submit").click()

driver.switch_to.parent_frame()
WebDriverWait(driver,10).until(expected_conditions.presence_of_element_located((By.LINK_TEXT,"签退")))
driver.find_element(By.LINK_TEXT,"签退").click()







